package com.ccnu.JobHub.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ccnu.JobHub.mapper.StudentTagMapper;
import com.ccnu.JobHub.model.database.StudentTag;
import com.ccnu.JobHub.service.IStudentTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class StudentTagService extends ServiceImpl<StudentTagMapper, StudentTag> implements IStudentTagService {
    @Autowired
    private StudentTagMapper studentTagMapper;

    @Override
    public List<Map<String, Object>> getTagCount(){
        QueryWrapper<StudentTag> studentTagQueryWrapper = new QueryWrapper<StudentTag>()
                .select("tag_id as tagId","count(*) as amount")
                .groupBy("tagId")
                .orderByAsc("amount");
        Page<Map<String, Object>> page = Page.of(1,8);
        return studentTagMapper.selectMapsPage(page,studentTagQueryWrapper).getRecords();
    }
}
